home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 11 / Cream of the Crop 11-1.iso / comm / ftp4w24b.zip / vb / ftpproto.bas < prev    next >
BASIC Source File  |  1995-01-18  |  2KB  |  95 lines

  1. 'FTP_UTIL.BAS
  2. 'contains all global variables for the application
  3. 'and some routines
  4. '
  5. Global Const Dir_file = "C:\WINDOWS\FTP_UTIL.LIS" 'dir list info
  6. '
  7. Global HostName As String
  8. Global Userid As String
  9. Global Password As String
  10. Global Sessie As String
  11. '
  12. Global Connected As Integer   'flag to indicate connection
  13. Global OkDialog As Integer    'return variable from other forms
  14. Global Success As Integer     'return variable from Ftp functions
  15. Global Transtype As Integer   'should be Asc("A") or Asc("I")
  16. Global DirType As Integer     'True = long; False = short
  17. Global MaskType As String     'default = *.*
  18. Global Src_nam As String      'source file name
  19. Global Dest_nam As String     'destination file name
  20. '
  21.  
  22.  
  23. Sub Do_the_dirlist ()
  24.   'list directory info in a file identified with Dir_file
  25.   'read the contents of that file and put results in
  26.   'listbox Dir_list
  27.   '
  28.   Dim d_File
  29.   Filt$ = MaskType
  30.   d_File = Dir_file
  31.   If Connected Then
  32.     Ftp_form!Dir_list.Clear
  33.     Success = FtpDir(Filt$, d_File, DirType, Hwnd, Ms%)
  34.     If Success = FTPERR_OK Then
  35.       Show_the_dir_list
  36.     Else
  37.       M$ = FTP4W_Error(Success)
  38.       Ftp_form!Message.Caption = M$
  39.     End If
  40.   End If
  41.   '
  42. End Sub
  43.  
  44. Function Get_mask_type () As String
  45.   '
  46.   Dim Answer$, DefVal, Msg, Title
  47.   '
  48.   DefVal = MaskType
  49.   Msg = "Enter file mask : "
  50.   Title = "File mask"
  51.   '
  52.   Answer = InputBox$(Msg, Title, DefVal)
  53.   '
  54.   Get_mask_type = Answer
  55.   '
  56. End Function
  57.  
  58. Sub Show_the_dir_list ()
  59.   'read the file and display the contents in the
  60.   'list box
  61.   '
  62.   Dim Lines As Integer, FileNum As Integer
  63.   Dim Txt As String, Ch As String * 1
  64.   '
  65.   FileNum = FreeFile
  66.   Lines = 0
  67.   '
  68.   On Error GoTo Err_term
  69.   Open Dir_file For Input As #FileNum
  70.   Txt = ""
  71.   Do While Not EOF(FileNum)
  72.     Ch = Input$(1, #FileNum)
  73.     If Ch <> Chr$(13) Then
  74.       Txt = Txt & Ch
  75.     Else
  76.       Lines = Lines + 1
  77.       Ftp_form!Dir_list.AddItem Txt
  78.       Txt = ""
  79.       Ch = Input$(1, #FileNum)  'read the linefeed
  80.     End If
  81.   Loop
  82.   Close #FileNum
  83.   '
  84.   If Lines = 0 Then
  85.     Txt = "No files found"
  86.     Ftp_form!Dir_list.AddItem Txt
  87.   End If
  88.   Exit Sub
  89.   '
  90. Err_term:
  91.   Ftp_form!Message.Caption = "Error in Dir list file"
  92.   Exit Sub
  93. End Sub
  94.  
  95.